package io.kiki.sba.registry.server.clientInterface.remoting.handler;

import io.kiki.sba.registry.api.Channel;
import io.kiki.sba.registry.common.model.client.pb.MetaHeartbeatRequest;
import io.kiki.sba.registry.common.model.client.pb.MetaHeartbeatResponse;
import io.kiki.sba.registry.util.StringUtil;
import lombok.NonNull;

import java.util.List;


public class MetaRevisionHeartbeatPbHandler extends AbstractClientMetadataRequestHandler<MetaHeartbeatRequest> {

    @Override
    public void checkParam(@NonNull MetaHeartbeatRequest request) {

        StringUtil.checkNotEmpty(request.getRevisionsList(), "request.revisions");
    }

    @Override
    public Object doHandle(Channel channel, MetaHeartbeatRequest request) {
        List<String> revisions = request.getRevisionsList();
        MetaHeartbeatResponse response = appRevisionHandlerStrategy.heartbeat(revisions);
        return response;
    }

    @Override
    public Class interest() {
        return MetaHeartbeatRequest.class;
    }
}
